package com.project.nimsen.service.impl;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import com.project.nimsen.dao.IBaseDao;
import com.project.nimsen.entity.Qrcodecard;
import com.project.nimsen.service.IQrcodecardService;
import com.project.jdbc.dao.IBaseJdbcDao;
import com.project.jdbc.service.BaseServiceImpl;
import com.project.jdbc.utils.Finder;
@Repository("qrcodecardService")
public class QrcodecardServiceImpl extends BaseServiceImpl implements
		IQrcodecardService {
	private String columns = "id,siteid,cname,cemail,cmodelphone,cphone,"
		+ "caddress,company,cduty,cperhomepage,cbak,createTime,active";
	@Resource
	IBaseDao baseDao;
	protected IBaseJdbcDao getBaseDao() {
		return baseDao;
	}
	@Override
	public Qrcodecard findByphone(String phoneNumber, String siteid) throws Exception {
		if(StringUtils.isBlank(phoneNumber)||StringUtils.isBlank(siteid))
			return null;
		Finder finder = new Finder("select ");
		finder.append(columns);
		finder.append(" from qrcodecard where active!=1 and siteid=:siteid and (cmodelphone="
			+ ":modelphone or cphone=:phone)");
		finder.setParam("modelphone", phoneNumber);
		finder.setParam("phone", phoneNumber);
		finder.setParam("siteid", siteid);
		return baseDao.queryForObject(finder, Qrcodecard.class);
	}
}
